/**
 * @ModuleInstancePair.java  COPYRIGHT xiaojian
 * 
 * Created on 2017年7月7日 下午4:43:35
 */
package xj.toolkit.access.dispatcher;

import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * 模块id，实例id。
 * 
 * @author <a href="mailto:cxj2000@gmail.com">xiaojian.cao</a>
 *
 */
class ModuleInstancePair {

	private short moduleId = 0;

	private short instanceId = 0;
	
	public ModuleInstancePair(){}
	
	public ModuleInstancePair(short moduleId, short instanceId) {
		this.moduleId = moduleId;
		this.instanceId = instanceId;
	}

	public int getModuleId() {
		return moduleId;
	}

	public void setModuleId(short moduleId) {
		this.moduleId = moduleId;
	}

	public short getInstanceId() {
		return instanceId;
	}

	public void setInstanceId(short instanceId) {
		this.instanceId = instanceId;
	}

	public boolean equals(Object other) {
		if (other == null || !(other instanceof ModuleInstancePair)) {
			return false;
		}

		ModuleInstancePair pair = (ModuleInstancePair) other;

		return pair.instanceId == instanceId && pair.moduleId == moduleId;
	}
	
	public int hashCode() {  
        int result = 17;  
        result = result * 31 + moduleId;  
        result = result * 31 + instanceId;  

        return result;  
    } 
	
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
}
